cd "c:\users\\`c(username)'\dropbox\TingleyCostaRica\ISQ\data"
use CR_ISQdistrict.dta  , clear

local targetind2 "AgricExports ManufExports PcntTextile "
local targetind " ManufExports   "
local rv "BrozExport BrozImport"
local ss "PcntLowSocEcon_SD"
local control "totalunemp pubempperc"
local controlfe "pubempperc"
local edu "colortv"
local ftz "ftzbusinesses_dum"
local cluster "cl(cantonid)"

local i=1
estimates clear
reg perc_yes pct_PLN_leg06 pct_PAC_leg06 pct_PUSC_leg06  pct_Libertario_leg06  `targetind' `ftz' `ss' `control' `edu', robust `cluster'
est store Leg`i'
local i=`i'+1

xtreg perc_yes pct_PLN_leg06 pct_PAC_leg06 pct_PUSC_leg06 pct_Libertario_leg06  `targetind' `ss' `controlfe' `edu' `ftz'  , robust  `cluster' fe
est store Leg`i'
gen samp = e(sample)
local i=`i'+1
reg perc_yes diff0602PLN_centered diff0602PAC_centered  diff0602PUSC_centered diff0602LIBER_centered  `targetind' `ss' `control' `edu' `ftz'  , robust  `cluster' 
est store Leg`i'
local i=`i'+1
xtreg perc_yes diff0602PLN_centered diff0602PAC_centered  diff0602PUSC_centered diff0602LIBER_centered  `targetind' `ss' `controlfe' `edu' `ftz'  , robust  `cluster' fe
est store Leg`i'
local i=`i'+1
local order "order(pct* diff*)"

preserve
use CR_ISQ_ED.dta , clear
local targetind2 "AgricExports ManufExports PcntTextile "
local targetind " ManufExports   "
local rv "BrozExport BrozImport"
local ss "PcntLowSocEcon_SD"
local control "totalunemp pubempperc"
local controlfe "pubempperc"
*local edu "universityeduc"
*local edu "colortv universityeduc"
local edu "colortv"
local ftz "ftzbusinesses_dum"
local cluster "cl(cantonnumb)"
areg perc_yes pct_PLN_leg06 pct_PAC_leg06 pct_PUSC_leg06 pct_Libertario_leg06  `targetind' `ss' `controlfe' `edu' `ftz'  , robust  `cluster' abs(cantonnumb)
est store leg_cfe

areg perc_yes pct_PLN_leg06 pct_PAC_leg06 pct_PUSC_leg06 pct_Libertario_leg06 /* `targetind' `ss' `controlfe' `edu' `ftz'  */, robust  `cluster' abs(distnum)
est store leg_dfe

areg perc_yes diff0602PLN_centered diff0602PAC_centered  diff0602PUSC_centered diff0602LIBER_centered  `targetind' `ss' `controlfe' `edu' `ftz'  , robust  `cluster' abs(cantonnumb)
est store leg_dcfe

areg perc_yes diff0602PLN_centered diff0602PAC_centered  diff0602PUSC_centered diff0602LIBER_centered /* `targetind' `ss' `controlfe' `edu' `ftz'  */, robust  `cluster' abs(provnum)
est store leg_ddfe

restore

estout Leg* leg_cfe leg_dcfe leg_dfe using "Table1.txt" , /*
	*/ cells(b(star fmt(%8.2f)) se(par)) starlevels(+ .1 * .05 ** .01) 	/*
	*/ stats(N bic r2 r2_b, fmt(%9.0f %8.2f) labels(Observations BIC)) legend 	/*
	*/ collabels(, none) `order' label varlabels(_cons Constant) replace

	
